Echo off
:Main
  	Set SiteDest=%~dp0\..\target\siteToDeploy
  	Set SiteDest=H:\Workspaces\Kaamelot.Softwares\kaamelot.fr.free.fr
  	Md %SiteDest%
  	Call :CopyAllJars
	Rem Call :CopyJarSites
	Rem Call :MoveSites
	Pause	
  Goto :EOF
  
:CopyAllJars
	Call :CopyJarSite %~dp0\..\ .
	Pushd H:\Workspaces\3.13\Atlassian.Plugins
		Call :CopyJars .\jira-plugin-kaamelot-parent
		Call :CopyJars .\jira-plugin-kaamelot-core
		Call :CopyJars .\jira-plugin-kaamelot-i18n
		Call :CopyJars .\jira-plugin-kaamelot-settings
		
		Call :CopyJars .\jira-plugin-myrddin-parent
		Call :CopyJars .\jira-plugin-myrddin-core
		Call :CopyJars .\jira-plugin-myrddin-i18n
		Call :CopyJars .\jira-plugin-myrddin-settings
		
		Call :CopyJars .\jira-plugin-kaamelot-site
		Call :CopyJars .\jira-plugin-myrddin-site
	PopD
  Goto :EOF
  
:CopyJarSites
	Call :CopyJarSite %~dp0\..\ .
	Pushd H:\Workspaces\3.13\Atlassian.Plugins
		Call :CopyJarSite .\jira-plugin-kaamelot-parent 	jiraPlugins\jira-plugin-kaamelot-parent
		Call :CopyJarSite .\jira-plugin-kaamelot-core 		jiraPlugins\jira-plugin-kaamelot-parent\jira-plugin-kaamelot-core
		Call :CopyJarSite .\jira-plugin-kaamelot-i18n 		jiraPlugins\jira-plugin-kaamelot-parent\jira-plugin-kaamelot-i18n
		Call :CopyJarSite .\jira-plugin-kaamelot-settings 	jiraPlugins\jira-plugin-kaamelot-parent\jira-plugin-kaamelot-settings
		
		Call :CopyJarSite .\jira-plugin-myrddin-parent 		jiraPlugins\jira-plugin-myrddin-parent
		Call :CopyJarSite .\jira-plugin-myrddin-core 		jiraPlugins\jira-plugin-myrddin-parent\jira-plugin-myrddin-core
		Call :CopyJarSite .\jira-plugin-myrddin-i18n 		jiraPlugins\jira-plugin-myrddin-parent\jira-plugin-myrddin-i18n
		Call :CopyJarSite .\jira-plugin-myrddin-settings 	jiraPlugins\jira-plugin-myrddin-parent\jira-plugin-myrddin-settings
		
		Call :CopyJarSite .\jira-plugin-kaamelot-site 		jiraPlugins\jira-plugin-kaamelot-site
		Call :CopyJarSite .\jira-plugin-myrddin-site 		jiraPlugins\jira-plugin-myrddin-site
	PopD
  Goto :EOF
  
:MoveSites
	Pushd H:\Workspaces\3.13\Atlassian.Plugins
		Call :MoveSite jira-plugin-kaamelot-site jiraPlugins
		rem Call :MoveSite jira-plugin-myrddin-site jiraPlugins
		
		Call :MoveSite jira-plugin-kaamelot-parent  jiraPlugins\jira-plugin-kaamelot-site
		Call :MoveSite jira-plugin-kaamelot-parent\jira-plugin-kaamelot-core  jiraPlugins\jira-plugin-kaamelot-site
		
		
		Call :MoveSite jira-plugin-kaamelot-parent\jira-plugin-kaamelot-i18n  jiraPlugins\jira-plugin-kaamelot-site
		Call :MoveSite jira-plugin-kaamelot-parent\jira-plugin-kaamelot-settings  jiraPlugins\jira-plugin-kaamelot-site
		
		Goto :Next

		Call :MoveSite jira-plugin-myrddin-parent  jiraPlugins\jira-plugin-myrddin-site
		Call :MoveSite jira-plugin-myrddin-parent\jira-plugin-myrddin-core  jiraPlugins\jira-plugin-myrddin-site
		Call :MoveSite jira-plugin-myrddin-parent\jira-plugin-myrddin-i18n  jiraPlugins\jira-plugin-myrddin-site
		Call :MoveSite jira-plugin-myrddin-parent\jira-plugin-myrddin-settings  jiraPlugins\jira-plugin-myrddin-site
		:Next		
	PopD
  Goto :EOF
  
:MoveSite
	Echo Move .\%1\target\site %SiteDest%\%2\%1
	pause
	rd /q/s  %SiteDest%\%2\%1
	Move .\%1\target\site %SiteDest%\%2\%1
	pause
  Goto :EOF

:CopyJars
	FOR /F %%j IN ('dir /b/s %1*-site.jar') Do Copy %%j %SiteDest%
  Goto :EOF

:CopyJarSite
	Md %SiteDest%\%2
	FOR /F %%j IN ('dir /b/s %1*-site.jar') Do Copy %%j %SiteDest%\%2
  Goto :EOF

:End
  Pause
